<?php
function mockChangePath($path)
{
    if (strpos($path, '.') === false || strpos($path, '..') === false) {
        return rtrim($path, '/');
    }

    $sub_path_list = explode('/', rtrim($path, '/'));
    $sub_path_list = array_map(function ($path) {
        return $path == "" ? "/" :$path;
    }, $sub_path_list);

    $target_path_list = array();
    foreach ($sub_path_list as $sub_path_item) {
        if ($sub_path_item != "." && $sub_path_item != "..") {
            $target_path_list[] = $sub_path_item;
            continue;
        }
        if ($target_path_list == "..") {
            $target_path_list = array_slice($target_path_list,0, count($target_path_list)-1);
        }
    }
    return implode('/', $target_path_list);
}
var_dump(mockChangePath('/a/./b/../../c/'));